<%--
  Created by IntelliJ IDEA.
  User: aa
  Date: 2019/07/15
  Time: 15:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keys" content="">
    <meta name="author" content="">
    <link rel="stylesheet" href="${APP_PATH}/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${APP_PATH}/css/font-awesome.min.css">
    <link rel="stylesheet" href="${APP_PATH}/css/login.css">
    <style>

    </style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <div><a class="navbar-brand" href="index.html" style="font-size:32px;">阿璐4r-众筹平台</a></div>
        </div>
    </div>
</nav>

<div class="container">

    <form id="loginFrom" action="${APP_PATH }/doLogin.do" class="form-signin" role="form">
        ${exception.message }
        <h2 class="form-signin-heading"><i class="glyphicon glyphicon-log-in"></i> 用户登录</h2>
        <div class="form-group has-success has-feedback">
            <input name="loginacct" type="text"  class="form-control" id="floginacct" placeholder="请输入登录账号" autofocus>
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
        </div>
        <div class="form-group has-success has-feedback">
            <input name="userpswd" type="password" class="form-control" id="fuserpswd" placeholder="请输入登录密码"
                   style="margin-top:10px;">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        </div>
        <div class="form-group has-success has-feedback">
            <select class="form-control" name="type" id="ftype">
                <option id="member" value="member">会员</option>
                <option id="user" value="user">管理</option>
            </select>
        </div>
        <div class="checkbox">
            <label>
                <input id="remember" type="checkbox"  value="1">记住我
            </label>
            <br>
            <label>
                忘记密码
            </label>
            <label style="float:right">
                <a href="${APP_PATH}/register.htm">我要注册</a>
            </label>
        </div>
        <a class="btn btn-lg btn-success btn-block" onclick="dologin()" id="loginBtn"> 登录</a>
    </form>
</div>
<script src="${APP_PATH}/jquery/jquery-2.1.1.min.js"></script>
<script src="${APP_PATH}/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${APP_PATH}/jquery/layer/layer.js"></script>
<script>

    function dologin() {

        var floginacct = $("#floginacct");
        var fuserpswd = $("#fuserpswd");
        var ftype = $("#ftype");

        if ($.trim(floginacct.val()) == "") {
            //alert("用户账号不能为空！");
            layer.tips("账号不能为空", "#floginacct");
            floginacct.val("");
            floginacct.focus();
            return false;
        }
        if ($.trim(fuserpswd.val()) == "") {
            layer.tips("密码不能为空", "#fuserpswd");
            fuserpswd.val("");
            fuserpswd.focus();
            return false;
        }
        var flag = $("#remember")[0].checked;//是否选中记住我
        $.ajax({
            type: "POST",
            data: {
                "loginacct": floginacct.val(),
                "userpswd": fuserpswd.val(),
                "type": ftype.val(),
                "remember": flag?"1":"0",
            },
            url: "${APP_PATH}/doLogin.do",

            beforeSend: function () {
                return true;
            },
            success: function (ajaxResult) {
                if (ajaxResult.success) {
                    if("member"==ajaxResult.data){
                        window.location.href = "${APP_PATH}/member/toIndex.htm";
                    }else if("user"==ajaxResult.data){
                        window.location.href = "${APP_PATH}/main.htm";
                    }

                } else {
                    layer.tips("账号或者密码错误", "#loginBtn");
                }
            },
            error: function () {
                alert("error");
            },

        });


        //$("#loginFrom").submit();
    }
</script>
</body>
</html>
